package com.wx.sys.service;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.wx.sys.dao.Wx_sys_rpersion_DAO;
import com.wx.sys.entity.Wx_sys_rpersion;

/**
 * 角色权限
 * 
 * @author lenovo
 *
 */
@Transactional(readOnly = true)
@Service("Wx_sys_rpersion_Service")
public class Wx_sys_rpersion_Service {
	@Resource(name = "Wx_sys_rpersion_DAO")
	private Wx_sys_rpersion_DAO wx_sys_rpersion_DAO;

	/**
	 * 新增
	 */
	@Transactional(readOnly = false, isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
	public boolean add(Wx_sys_rpersion wx_sys_rpersion) throws Exception {
		Integer result = wx_sys_rpersion_DAO.add(wx_sys_rpersion);
		return result > 0 ? true : false;
	}

	/**
	 * 删除
	 */
	@Transactional(readOnly = false, isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
	public boolean delete(java.lang.Long rid, java.lang.Long mid, Long perssionId) throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();
		if (rid != null) {
			map.put("role_id", rid);
		}
		if (mid != null) {
			map.put("menu_id", mid);
		}
		if (perssionId != null) {
			map.put("perssionId", perssionId);
		}
		Integer result = wx_sys_rpersion_DAO.deleteData(map);
		return result > 0 ? true : false;
	}
}
